 impl Solution {
    pub fn num_distinct(s: String, t: String) -> i32 {
        let mut bp =vec!(vec!(-1;t.len());s.len());
        return Solution::num_f(s.as_bytes(), t.as_bytes(),0, 0, &mut bp);
    }
    fn num_f(s:&[u8],t :&[u8],i:usize,j:usize,bp:&mut[Vec<i32>])->i32{
        if i>=s.len()||j>=t.len(){
            return 0;
        }
        if bp[i][j]!=-1{
            return bp[i][j];
        }
        if s.len()-i <t.len()-j{
            bp[i][j]=0;
            return  bp[i][j];
        }
        
        if s[i]==t[j]{
            if j==t.len()-1{
                bp[i][j]=1+Solution::num_f(s, t, i+1, j, bp);
            }else{
                bp[i][j]= Solution::num_f(s, t, i+1, j+1, bp)+Solution::num_f(s, t, i+1, j, bp);
            }
            
        }else{
            bp[i][j]= Solution::num_f(s, t, i+1, j, bp);
        }
        bp[i][j]
    }
}
